<template>
	<view class="content">
		<view class="list">
			<view class="list-box dis_f_sb_c" v-for="(item, index) in list" @click="go()">
				<view class="list-left">
					<img :src="img_src + item.image" />
					<view class="status"
						:style="{background:item.stock <= 0 ? '#FF4435':item.shangjia == 0?'#838383':'#016FDD' }">
						{{item.stock <= 0 ? '售罄':item.shangjia == 0?'下架中':'出售中' }}
					</view>
				</view>
				<view class="list-item">
					<view class="tit">{{item.name}}<view>去鉴定</view> </view>

					<view class="desc">月{{item.stock}}吨 </view>

					<view class="time">¥ {{item.price}}/吨
						<zb-tooltip color="white" content="Bottom" placement="left-end" ref="tooltip6">
							<u-icon name="more-dot-fill"></u-icon>
							<view slot="content">
								<view class="tip">
									<view @click="edit(item.id)">编辑</view>
									<view @click="change_type(item.id)">{{item.shangjia == 0 ? '上架':'下架'}}</view>
									<view @click="del(item.id)" style="border: none;margin-bottom: 0;">删除</view>
								</view>
							</view>
						</zb-tooltip>
					</view>
					<view style="display: flex;width: 100%;justify-content:flex-end">
						<view @click="gojianding(item.id)" style="font-weight: bold;padding: 10rpx;color: #fff;background-color: #016fdd;width: 120rpx;border-radius: 18rpx;text-align: center;">去鉴定</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		name: "index",
		components: {},
		props: {
			list: {
				type: Array,
				default: []
			}
		},
		data() {
			return {
				isShow: false,
				img_src: this.$.img_src
			};
		},
		methods: {
			gojianding(e){
				this.$.open('/pages/appraisalOEM/appraisalServices?id=' + e)
			},
			edit(e) {
				this.$.open('/pages/release/form?type=1&id=' + e)
			},
			del(e) {
				this.$.ajax(1, "POST", "user/deletegood", {
					gid: e
				}, (res) => {
					this.$.ti_shi(res.msg)
					if (res.code == 1) {
						this.$emit('getGoods')
					}
				})
			},
			change_type(e) {
				console.log(e)
				this.$.ajax(1, "POST", "user/setgoodstatus", {
					gid: e
				}, (res) => {
					this.$.ti_shi(res.msg)
					if (res.code == 1) {
						this.$emit('getGoods')
					}
				})
			},
			go() {
				// uni.navigateTo({url: '/pages/buy/buyDetails'})
			},
		},
		created() {},
		mounted() {},
	};
</script>

<style lang="scss" scoped>
	.content {
		margin: 0 20rpx;

		.list {
			padding: 20rpx 0 10rpx 0;

			.list-box {
				display: flex;
				margin-bottom: 20rpx;

				.list-left {
					flex-shrink: 0;

					width: 200rpx;
					height: 200rpx;
					position: relative;

					img {
						width: 100%;
						height: 100%;
						border-radius: 12rpx;
					}

					.status {
						position: absolute;
						bottom: 0;
						width: 100%;
						color: #ffffff;
						background-color: #016fdd;
						height: 46rpx;
						line-height: 46rpx;
						font-size: 24rpx;
						font-weight: 500;
						text-align: center;

						border-radius: 0 0 12rpx 12rpx;
					}
				}
			}

			.list-item {
				flex: 1;
				// margin-bottom: 20rpx;
				border-right: 12rpx;
				padding: 20rpx;
				background-color: #fff;
				//   display: flex;
				//   flex-direction: column;
				//   gap: 20rpx;
				color: #666666;
				font-size: 28rpx;
				// border-bottom: 1rpx solid #f4f4f4;
				padding-top: 0;

				.tit {
					font-size: 28rpx;
					color: #131313;
					font-weight: 700;
				}

				.time {
					//color: #999999;
					flex: 1;
					font-size: 28rpx;
					font-weight: 700;
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 40rpx;

					.tip {
						display: flex;
						flex-direction: column;
						align-items: center;
						color: #393b3a;
						width: 94rpx;
						justify-content: space-between;
						font-size: 24rpx;
						font-weight: 500;

						view {
							padding-bottom: 10rpx;
							margin-bottom: 10rpx;
							border-bottom: 1rpx solid #ececec;
						}
					}
				}

				.desc {
					color: #999999;
					flex: 1;
					font-size: 20rpx;
					font-weight: 400;
					margin-top: 12rpx;
				}
			}
		}
	}
</style>